var chartLeftBtm = echarts.init(document.getElementById("left-btm"));

function chartLeftBtmFunc() {
  $.ajax({
    type: "get",
    url: baseUrl + "aqi/getAqiTrendStatisticLast12",
    success: function (data) {
      var dateList = [];
      var valueList = [];
      for (const v of data.data) {
        dateList.push(formatDate(new Date(v.date)));
        valueList.push(v.count);
      }
      dateList.reverse();
      valueList.reverse();
      var optionChartLeftBtm = {
        title: {
          show: true,
          text: "12个月内空气质量超标趋势",
          textStyle: {
            color: "#fff", //'red'，字体颜色
            fontStyle: "normal", //'italic'(倾斜) | 'oblique'(倾斜体) ，字体风格
            fontWeight: "normal", //'bold'(粗体) | 'bolder'(粗体) | 'lighter'(正常粗细) ，字体粗细
            fontFamily: "sans-serif", //'sans-serif' | 'serif' | 'monospace' | 'Arial' | 'Courier New'
            // 'Microsoft YaHei'(微软雅黑) ，文字字体
            fontSize: 14, //字体大小
            lineHeight: 14, //字体行高
          },
          textAlign: "auto", //整体（包括 text 和 subtext）的水平对齐
          textVerticalAlign: "auto", //整体（包括 text 和 subtext）的垂直对齐
          //padding:0,//[5,10] | [ 5,6, 7, 8] ,标题内边距
          left: "30%", //'5' | '5%'，title 组件离容器左侧的距离
          right: "auto", //'title 组件离容器右侧的距离
          top: "5%", //title 组件离容器上侧的距离
          bottom: "auto", //title 组件离容器下侧的距离
        },
        tooltip: {
          trigger: "axis", // 触发类型，默认数据触发，可选为：'item', 'axis'
        },
        xAxis: {
          type: "category",
          axisLabel: {
            color: "white",
          },
          data: dateList,
        },
        yAxis: {
          type: "value",
          axisLabel: {
            color: "white",
          },
        },
        series: [
          {
            data: valueList,
            type: "line",
            smooth: true,
          },
        ],
      };

      chartLeftBtm.setOption(optionChartLeftBtm);
    },
  });
}

chartLeftBtmFunc();
